The Kotlin when
statement can not only be used to compare a selector against a list of values, but also to select from a list of
conditions.
This is a more readable and elegant alternative to a chain of if
statements and should be used instead.
What is the potential impact?
Readability and Understanding
This change makes it easier to understand a function because it will reduce its complexity. This is because a single when
statement
has less cognitive complexity than multiple if
statements, even if it has as many cases.